package cn.youqu.happy.module.youqu.dal.mysql.userInfo;

import java.util.*;

import cn.youqu.happy.framework.common.pojo.PageResult;
import cn.youqu.happy.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.youqu.happy.framework.mybatis.core.mapper.BaseMapperX;
import cn.youqu.happy.module.youqu.dal.dataobject.userInfo.UserInfoDO;
import org.apache.ibatis.annotations.Mapper;
import cn.youqu.happy.module.youqu.controller.admin.userInfo.vo.*;

/**
 * 用户信息 Mapper
 *
 * @author 王其岩 20112001045
 */
@Mapper
public interface UserInfoMapper extends BaseMapperX<UserInfoDO> {

    default PageResult<UserInfoDO> selectPage(UserInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserInfoDO>()
                .likeIfPresent(UserInfoDO::getNickName, reqVO.getNickName())
                .eqIfPresent(UserInfoDO::getAvatar, reqVO.getAvatar())
                .eqIfPresent(UserInfoDO::getMobile, reqVO.getMobile())
                .eqIfPresent(UserInfoDO::getHobbies, reqVO.getHobbies())
                .eqIfPresent(UserInfoDO::getStar, reqVO.getStar())
                .eqIfPresent(UserInfoDO::getFavorRate, reqVO.getFavorRate())
                .betweenIfPresent(UserInfoDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .eqIfPresent(UserInfoDO::getRemark, reqVO.getRemark())
                .orderByDesc(UserInfoDO::getId));
    }

    default List<UserInfoDO> selectList(UserInfoExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<UserInfoDO>()
                .likeIfPresent(UserInfoDO::getNickName, reqVO.getNickName())
                .eqIfPresent(UserInfoDO::getAvatar, reqVO.getAvatar())
                .eqIfPresent(UserInfoDO::getMobile, reqVO.getMobile())
                .eqIfPresent(UserInfoDO::getHobbies, reqVO.getHobbies())
                .eqIfPresent(UserInfoDO::getStar, reqVO.getStar())
                .eqIfPresent(UserInfoDO::getFavorRate, reqVO.getFavorRate())
                .betweenIfPresent(UserInfoDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .eqIfPresent(UserInfoDO::getRemark, reqVO.getRemark())
                .orderByDesc(UserInfoDO::getId));
    }

}
